package com.woniu.apiBoss.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniu.apiBoss.service.ApiDriverService;
import com.woniu.internalcommon.dto.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zcnovice
 * @data 2025/7/15 上午10:24
 */
@RestController
@RequestMapping("/driver")
@CrossOrigin
public class ApiDriverController {
    @Autowired
    private ApiDriverService apiDriverService;

    /* 修改司机 */
    @PutMapping("/update")
    public ResponseResult update(@RequestBody DriverUser driverUser) {
        ResponseResult update = apiDriverService.update(driverUser);
        return update;
    }

    /* 增加司机 */
    @PostMapping("/add")
    public ResponseResult add(@RequestBody DriverUser driverUser) {
        ResponseResult add = apiDriverService.add(driverUser);
        return add;
    }

    /* 分页+条件+连表  查询司机 */
    @PostMapping("/find")
    public ResponseResult<Page<DriverUser>> find(@RequestBody ApiBossDriver apiBossDriver) {

        return apiDriverService.find(apiBossDriver);
    }

    /* 绑定汽车 */
    @PostMapping("/binding")
    public ResponseResult binding(@RequestBody DriverCarBindingRelationship driverCarBindingRelationship) {
        ResponseResult binding = apiDriverService.binding(driverCarBindingRelationship);
        return binding;
    }

    /* 解绑汽车 */
    @DeleteMapping("/unbind")
    public ResponseResult unbind(@RequestBody DriverCarBindingRelationship driverCarBindingRelationship) {
        ResponseResult unbind = apiDriverService.unbind(driverCarBindingRelationship);
        return unbind;
    }

    @PostMapping("/getAllCar")
    public ResponseResult<Page<Car>> getAllCar(@RequestBody ApiBossCar apiBossCar) {
        return apiDriverService.getAllCar(apiBossCar);
    }


}
